<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <div class="datalist"><table id="flexigrid" style="display:none"></table></div>
        <script type="text/javascript">
            $(function() {
                $("#flexigrid").flexigrid($.extend(SG.flexOptions, {
                    url: '<?= site_url('cdkey/cdkeyview/flexigrid') ?>',
                    colModel: [
                      {display: '<?= translate('CDKEY_ID') ?>', name: 'id', width: 80, iskey: true , hide:true, },
                      {display: '<?= translate('CDKEY_KEYCHAR') ?>', name: 'keyChar', width: 180},
                      {display: '<?= translate('CDKEY_CHANNEL') ?>', name: 'channel', width: 80},
                      {display: '<?= translate('CDKEY_VIP_LIMIT') ?>', name: 'viplevel', width: 80},
                      {display: '<?= translate('CDKEY_AREAID') ?>', name: 'areaid', width: 80},
                      //{display: '<?= translate('CDKEY_KEYTYPE') ?>', name: 'keytype', width: 150},
                      {display: '<?= translate('CDKEY_STARTTIME') ?>', name: 'starttime', width: 150},
                      {display: '<?= translate('CDKEY_ENDTIME') ?>', name: 'endtime', width: 150},
                      {display: '<?= translate('CDKEY_REWARDOBJECT') ?>', name: 'rewardobjectid', width: 100},
                      {display: '<?= translate('CDKEY_ROLEID') ?>', name: 'roleid', width: 80},
                      {display: '<?= translate('CDKEY_ISUSE') ?>', name: 'isuse', width: 80},
                      {display: '<?= translate('CDKEY_CREATETIME') ?>', name: 'createtime', width: 150},
                      //{display: '<?= translate('MANAGE') ?>', name: 'id', width: 80, sortable: false, process: formatOp}
                    ],
                    buttons: [
                      //{name: 'add', displayname: "<?= translate('ADD') ?>", title: "<?= translate('ADD') ?>", bclass: 'add', onpress: multi},
                      {name: 'export', displayname: "<?= translate('EXPORT') ?>", bclass: 'export', onpress: multi},
                      {name: 'delete', displayname: "<?= translate('DEL') ?>", title: "<?= translate('DEL') ?>", bclass: 'delete', onpress: multi},
                      //{name: 'copyToOther', displayname: "<?= translate('COPY_TO_OTHER_AREA') ?>", title: "<?= translate('COPY_TO_OTHER_AREA') ?>", onpress:multi},
                      //{name: 'copyToOther', displayname: "<?= translate('COPY_TO_OTHER_AREA') ?>", title: "<?= translate('COPY_TO_OTHER_AREA') ?>", onpress:toolbarItem},
                    ],
                    searchitems: true,
                }));
                SG.admin = $.extend(SG.admin, {
                  //add_url: '<?= site_url("cdkey/cdkeyview/add") ?>',
                  //edit_url: '<?= site_url("cdkey/cdkeyview/edit/") ?>',
                  multi_url: '<?= site_url("cdkey/cdkeyview/multi/") ?>'
                });

              //按钮操作函数     
              function toolbarItem(com, grid) {
                var ids = $("#flexigrid").getCheckedRows();
                  alert('com = '+com+" grid = "+grid+" ids = "+ids); 
                  if (com=='copyToOther'){ 
                      if($('.trSelected',grid).length==0){ hiAlert("请选择要删除的数据!"); }
                      else{                hiConfirm('是否删除这 ' + $('.trSelected',grid).length + ' 条记录吗?', '操作提示', 
                              function(r)  {              
                          if(r){                 
                              var  ids ="";                     
                              $('.trSelected td:nth-child(2)',grid).each(function(){                     
                                  ids+=","+$(this).text();                    });
                              ids=ids.substring(1);
                              $.ajax({
                                  type: "POST",
                                  url: "<%=basePath %>admin/UserManagerServlet?action=delete",
                                  data: "ids="+ids, 
                                  dataType:"text",
                                  success: function(msg){
                                      if(msg=="success"){
                                          hiAlert("操作成功！");
                                          $("#JUserTable").flexReload();
                                          }else{
                                              hiAlert("有错误发生,msg="+msg);
                                              }
                                       },
                                       error: function(msg){                  hiAlert("msg="+msg);                 }
                                       });                     
                              }
                          });             
                      }              
                    }
              }
                
            });
        </script>       
    </body>
</html>